import tkinter as tk
from tkinter import filedialog

def empty_function():
    print("按钮被点击，但尚未绑定功能")

def select_file():
    filename = filedialog.askopenfilename()
    if filename:
        entry_table.delete(0, tk.END)
        entry_table.insert(0, filename)

def select_folder():
    foldername = filedialog.askdirectory()
    if foldername:
        entry_path.delete(0, tk.END)
        entry_path.insert(0, foldername)

root = tk.Tk()
root.title("图片上传设置")
root.geometry("700x280")  # 调整窗口尺寸，减少空白
root.configure(bg="#f0f0f0")

font_style = ("微软雅黑", 10)
entry_style = {"width": 50, "font": ("微软雅黑", 10)}  # 移除 height 参数
button_style = {"bg": "#3399FF", "fg": "white", "font": ("微软雅黑", 10), "bd": 0, "padx": 10, "pady": 2}  # 移除 height 参数

def create_label_entry(parent, label_text):
    frame = tk.Frame(parent, bg="#f0f0f0")
    frame.pack(anchor="w", padx=10, pady=2, fill="x")
    label = tk.Label(frame, text=label_text, font=font_style, bg="#f0f0f0", width=20, anchor="w")
    label.pack(side="left")
    entry = tk.Entry(frame, **entry_style)
    entry.pack(side="left", padx=10, pady=2, ipady=3, fill="x", expand=True)  # 使输入框填充剩余空间
    return entry

# 创建输入框和标签在同一行
entry_material = create_label_entry(root, "素材图（颜色-第几张[默认1]） 例：“黑色-2”）")
entry_variable = create_label_entry(root, "变量图（,分割）")
entry_detail = create_label_entry(root, "详情图（颜色-第几张[分割]） 例：“黑色-1,2”）")

# 设置表格
frame_table = tk.Frame(root, bg="#f0f0f0")
frame_table.pack(anchor="w", padx=10, pady=2, fill="x")
lbl_table = tk.Label(frame_table, text="设置表格", font=font_style, bg="#f0f0f0", width=20, anchor="w")
lbl_table.pack(side="left")
entry_table = tk.Entry(frame_table, **entry_style, fg="#808080")  # 暗淡无光的文本颜色
entry_table.pack(side="left", padx=10, pady=2, ipady=3, fill="x", expand=True)
btn_table = tk.Button(frame_table, text="选择", command=select_file, **button_style)
btn_table.pack(side="left", padx=10, pady=2)

# 设置图片路径
frame_path = tk.Frame(root, bg="#f0f0f0")
frame_path.pack(anchor="w", padx=10, pady=2, fill="x")
lbl_path = tk.Label(frame_path, text="设置图片路径", font=font_style, bg="#f0f0f0", width=20, anchor="w")
lbl_path.pack(side="left")
entry_path = tk.Entry(frame_path, **entry_style, fg="#808080")  # 暗淡无光的文本颜色
entry_path.pack(side="left", padx=10, pady=2, ipady=3, fill="x", expand=True)
btn_path = tk.Button(frame_path, text="选择", command=select_folder, **button_style)
btn_path.pack(side="left", padx=10, pady=2)

# 运行窗口
root.mainloop()
